# -*- coding: utf-8 -*-
"""
Created on Fri Apr 10 14:32:08 2020

@author: wjx
"""
from collections import OrderedDict

msg = "我是%(n1)s,年龄%(n2)s" % {'n1':'jack','n2':20}
print(msg)

v1 = "我是{0},年龄{1}".format('alex',19)
v11 = "我是{0},年龄{1}".format(*('alex',19))

v2 = "我是{name},年龄{age}".format(name='alex',age=19)
v22 = "我是{name},年龄{age}".format(**{'name':'alex','age':19})
print(v11)
print(v22)

#有序字典-------------------------------------------
info = OrderedDict()
info['k1'] = 123
info['k2'] = 456
#单例模式-------------------------------------
class Foo:
    instance = None
    def __new__(cls,*args,**kwargs):
        if not Foo.instance:
            Foo.instance = object.__new__(cls)
        return Foo.instance
    
obj1 = Foo()
obj2 = Foo()
print(obj1,obj2)
#日志————————————————————————————————————
import logging
logging.basicConfig(
    filename='cmdb.log',
    format='%(asctime)s - %(name)s - %(levelname)s - %(module)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M-%S %p',
    level=logging.ERROR   
    )
logging.error('alex')